package com.lyeducation.controllers.video;

import com.lyeducation.core.video.VideoTypeService;
import com.lyeducation.util.StringUtils;
import com.lyeducation.util.controllerUtil.JsonResult;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@Api(
        tags = {"videoType-api"},
        description = "视频类型接口{mId}需要传入菜单id，需要token"
)
@RestController
@RequestMapping("videoType/{mid}")
public class VideoTypeController {
    @Autowired
    private VideoTypeService videoTypeService;

    @ApiOperation(value = "查询所有视频类型", notes = "localhost:80/videoType/155824281657731102/getAllVideoType")
    @GetMapping("getAllVideoType")
    public JsonResult getAllVideoType() {
        return videoTypeService.getAllVideoType();
    }

    @ApiOperation(value = "新增视频类型", notes = "localhost:80/videoType/155824250681265405/addVideoType?type=物理")
    @GetMapping("addVideoType")
    public JsonResult addVideoType(String type) {
//        if (videoTypeService.getAllVideoType().isRel()) {
//            return JsonResult.putFail("已经存在该视频类型新增失败");
//        }
        return videoTypeService.addVideoType(StringUtils.trimToNull(type));
    }

    @ApiOperation(value = "删除视频类型", notes = "localhost:80/videoType/155824253848882300/delVideoType?type=物理")
    @GetMapping("delVideoType")
    public JsonResult delVideoType(String type) {
        return videoTypeService.delVideoType(StringUtils.trimToNull(type));
    }
}
